package spoon.task;

import org.jsoup.select.Elements;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import spoon.service.MarathonService;

@Component
public class MarathonFootballTask {

	@Autowired
	@Qualifier("marathonFootballService")
	private MarathonService marathonService;
	
	private Elements leagueList = new Elements();
	
	//@Scheduled(fixedRateString = "${marathon.football.delay}")
	public void taskGame() {
		// 링크 정보가 없을 경우 받아 온다.
		if (leagueList.size() == 0) {
			this.leagueList.addAll(marathonService.getLeagueList());
			return;
		}
		
		marathonService.getGame(leagueList.remove(0));
	}
	
}
